home *** CD-ROM | disk | FTP | other *** search
/ 3D Games (Spidla) / 3dhry1.iso / mAz Lite 1.0 / menu.wdl < prev    next >
Encoding:
Text File  |  2003-03-17  |  24.8 KB  |  978 lines

  1. // Template file v5.202 (02/20/02)
  2. ////////////////////////////////////////////////////////////////////////
  3. // File: menu.wdl
  4. //        WDL prefabs for simple game menus
  5. ////////////////////////////////////////////////////////////////////////
  6. //
  7.  
  8.  
  9.  
  10. ////////////////////////////////////////////////////////////////////////
  11. //
  12. ////////////////////////////////////////////////////////////////////////
  13.  
  14. IFNDEF MENU_DEFS;
  15.  SOUND  menu_click <click.wav>;    // menu select sound
  16.  DEFINE menu_font standard_font;    // menu font
  17.  BMAP button_low,<black.pcx>,0,0,64,10;// menu item background
  18.  BMAP button_hi,<white.pcx>,0,0,64,10;    // menu selected item background
  19.  BMAP yesno_back,<black.pcx>,0,0,64,24;// yes/no panel background
  20.  BMAP yesno_low,<black.pcx>,0,0,28,10;    // yes/no button background
  21.  BMAP yesno_hi,<white.pcx>,0,0,28,10;    // yes/no selected button background
  22.  BMAP arrow,<arrow.pcx>;// mouse pointer
  23.  DEFINE YES_OFFS_X,2;    // offsets for yes/no buttons to panel
  24.  DEFINE NO_OFFS_X,34;
  25.  DEFINE YESNO_OFFS_Y,12;
  26. ENDIF;    // MENU_DEFS
  27.  
  28. IFNDEF MENU_DEFS2;
  29.  DEFINE CONSOLE_MODE_2;    // console line don't disappear after [ENTER]
  30.  DEFINE INFO_NAME,"stat";
  31.  DEFINE SAVE_NAME,"game";
  32. ENDIF;
  33. //////////////////////////////////////////////////////////
  34. // legacy skills to be preserved on score loading & level change
  35. SKILL SOUND_VOL = { TYPE GLOBAL; VAL 100; }
  36. SKILL MIDI_VOL = { TYPE GLOBAL; VAL 50; }
  37.  
  38. //////////////////////////////////////////////////////////
  39. var menu_pos[2] = 10, 10;    // position of menu on screen
  40. var menu_dist[2] = 4, 12;    // distance between buttons
  41. var menu_offs[2] = 2,  1;     // offset text to button below
  42. var menu_max = 7;             // max items per menu
  43.  
  44. var yesno_pos[2] = 10, 10; // position of yes/no panel
  45. var yesno_offs[2] = 2,  2;    // offset text to panel
  46.  
  47. //////////////////////////////////////////////////////////
  48. // Texts and messages appearing in the menu
  49. STRING new_game_str," ";
  50. STRING load_game_str,"Load";
  51. STRING save_game_str,"Save";
  52. STRING quit_game_str,"Quit";
  53. STRING options_str,"Options";
  54. STRING help_str,"Help";
  55. STRING resume_str,"Back";
  56.  
  57. STRING yes_str,"Yes";
  58. STRING no_str," No";
  59.  
  60. STRING quit_yesno,"  Quit?";
  61.  
  62. STRING ok_str,"OK";
  63. STRING wait_str,"Please wait...";
  64. STRING save_error,"MALFUNCTION... can't save game";
  65. STRING load_error,"MALFUNCTION... save before loading!";
  66.  
  67. STRING helptxt_str,
  68. "ESC - Menu
  69. F1  - Help
  70. F2  - Quicksave
  71. F3  - Quickload
  72. F4  - Multiplayer message
  73. F5  - Toggle resolution
  74. F6  - Screenshot
  75. F7  - Toggle person mode
  76. F11 - Toggle gamma
  77. F12 - Toggle sound/music
  78. F10 - Exit";
  79.  
  80. //////////////////////////////////////////////////////////
  81. // a lot of default strings, actions and pointers
  82. // which are used for the items of the menu
  83.  
  84. var menu_cursor = 0;  // determines which item is selected
  85.  
  86. // strings for the names of the five games to save and load
  87. STRING name1_str,"         ";
  88. STRING name2_str,"         ";
  89. STRING name3_str,"         ";
  90. STRING name4_str,"         ";
  91. STRING name5_str,"         ";
  92.  
  93. string* mystring;
  94.  
  95. // pointers to the actions to execute for each of the 7 menu items
  96. action* menu_do1;
  97. action* menu_do2;
  98. action* menu_do3;
  99. action* menu_do4;
  100. action* menu_do5;
  101. action* menu_do6;
  102. action* menu_do7;
  103.  
  104. // pointers to save and restore any actions that were
  105. // previously assigned to menu keys
  106. action* old_menu_esc;
  107. action* old_help_esc;
  108. action* old_yesno_esc;
  109. action* old_menu_enter;
  110. action* old_yesno_enter;
  111. action* old_cud;
  112. action* old_cuu;
  113. action* old_cul;
  114. action* old_cur;
  115. action* old_f1;
  116.  
  117. // Actions which are really performed if clicking one of the 7 menu items.
  118. // The menu has to disappear before the action is executed
  119. function _b1() { _menu_clear(); menu_do1(); }
  120. function _b2() { _menu_clear(); menu_do2(); }
  121. function _b3() { _menu_clear(); menu_do3(); }
  122. function _b4() { _menu_clear(); menu_do4(); }
  123. function _b5() { _menu_clear(); menu_do5(); }
  124. function _b6() { _menu_clear(); menu_do6(); }
  125. function _b7() { _menu_clear(); menu_do7(); }
  126.  
  127. function _buttonclick() { PLAY_SOUND menu_click,40; }
  128.  
  129. // Texts on the menu item buttons
  130. TEXT menu_txt1 { LAYER 11; FONT menu_font; STRING empty_str; }
  131. TEXT menu_txt2 { LAYER 11; FONT menu_font; STRING empty_str; }
  132. TEXT menu_txt3 { LAYER 11; FONT menu_font; STRING empty_str; }
  133. TEXT menu_txt4 { LAYER 11; FONT menu_font; STRING empty_str; }
  134. TEXT menu_txt5 { LAYER 11; FONT menu_font; STRING empty_str; }
  135. TEXT menu_txt6 { LAYER 11; FONT menu_font; STRING empty_str; }
  136. TEXT menu_txt7 { LAYER 11; FONT menu_font; STRING empty_str; }
  137.  
  138. // The items of which the menu really consists.
  139. // Each item is a panel with a single button.
  140. PANEL menu_pan1
  141. {
  142.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  143.     BUTTON 0,0,button_hi,button_low,button_hi,_b1,NULL,_buttonclick;
  144. }
  145. PANEL menu_pan2
  146. {
  147.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  148.     BUTTON 0,0,button_hi,button_low,button_hi,_b2,NULL,_buttonclick;
  149. }
  150. PANEL menu_pan3
  151. {
  152.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  153.     BUTTON 0,0,button_hi,button_low,button_hi,_b3,NULL,_buttonclick;
  154. }
  155. PANEL menu_pan4
  156. {
  157.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  158.     BUTTON 0,0,button_hi,button_low,button_hi,_b4,NULL,_buttonclick;
  159. }
  160. PANEL menu_pan5
  161. {
  162.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  163.     BUTTON 0,0,button_hi,button_low,button_hi,_b5,NULL,_buttonclick;
  164. }
  165. PANEL menu_pan6
  166. {
  167.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  168.     BUTTON 0,0,button_hi,button_low,button_hi,_b6,NULL,_buttonclick;
  169. }
  170. PANEL menu_pan7
  171. {
  172.     LAYER 10; FLAGS REFRESH,TRANSPARENT;
  173.     BUTTON 0,0,button_hi,button_low,button_hi,_b7,NULL,_buttonclick;
  174. }
  175.  
  176. PANEL menu_select
  177. {
  178.     LAYER 10.5; BMAP button_hi; FLAGS REFRESH,TRANSPARENT;
  179. }
  180.  
  181. /////////////////////////////////////////////////////////////////////
  182. // This action initializes the menu
  183. // This just makes all menu items - buttons and texts above - visible on screen.
  184. function _menu_visible()
  185. {
  186.     if(menu_max >= 1)
  187.     {
  188.         menu_pan1.VISIBLE = ON;
  189.         menu_txt1.VISIBLE = ON;
  190.     }
  191.     if(menu_max >= 2)
  192.     {
  193.         menu_pan2.VISIBLE = ON;
  194.         menu_txt2.VISIBLE = ON;
  195.     }
  196.     if(menu_max >= 3)
  197.     {
  198.         menu_pan3.VISIBLE = ON;
  199.         menu_txt3.VISIBLE = ON;
  200.     }
  201.     if(menu_max >= 4)
  202.     {
  203.         menu_pan4.VISIBLE = ON;
  204.         menu_txt4.VISIBLE = ON;
  205.     }
  206.     if(menu_max >= 5)
  207.     {
  208.         menu_pan5.VISIBLE = ON;
  209.         menu_txt5.VISIBLE = ON;
  210.     }
  211.     if(menu_max >= 6)
  212.     {
  213.         menu_pan6.VISIBLE = ON;
  214.         menu_txt6.VISIBLE = ON;
  215.     }
  216.     if(menu_max >= 7)
  217.     {
  218.         menu_pan7.VISIBLE = ON;
  219.         menu_txt7.VISIBLE = ON;
  220.     }
  221.     FREEZE_MODE = 1;    // when the menu is on screen, the game freezes
  222.     menu_cursor = 1;    // place to first item
  223. }
  224.  
  225.  
  226. // This just lets all menu items disappear again
  227. function _menu_hide()
  228. {
  229.     menu_pan1.VISIBLE = OFF;
  230.     menu_txt1.VISIBLE = OFF;
  231.     menu_pan2.VISIBLE = OFF;
  232.     menu_txt2.VISIBLE = OFF;
  233.     menu_pan3.VISIBLE = OFF;
  234.     menu_txt3.VISIBLE = OFF;
  235.     menu_pan4.VISIBLE = OFF;
  236.     menu_txt4.VISIBLE = OFF;
  237.     menu_pan5.VISIBLE = OFF;
  238.     menu_txt5.VISIBLE = OFF;
  239.     menu_pan6.VISIBLE = OFF;
  240.     menu_txt6.VISIBLE = OFF;
  241.     menu_pan7.VISIBLE = OFF;
  242.     menu_txt7.VISIBLE = OFF;
  243.     menu_select.VISIBLE = OFF;
  244. }
  245.  
  246. // This quits the menu, restores old key actions, and continues the game
  247. function _menu_clear()
  248. {
  249.     if(menu_cursor > 0)
  250.     {
  251.         _menu_hide();
  252.         ON_ESC = old_menu_esc;
  253.         ON_CUU = old_cuu;
  254.         ON_CUD = old_cud;
  255.         ON_ENTER = old_menu_enter;
  256.         FREEZE_MODE = 0;
  257.         menu_cursor = 0;
  258.     }
  259. }
  260.  
  261. // One item up
  262. function _menu_up()
  263. {
  264.     menu_cursor -= 1;
  265.     _menu_set();
  266. }
  267.  
  268. // One item down
  269. function _menu_down()
  270. {
  271.     menu_cursor += 1;
  272.     _menu_set();
  273. }
  274.  
  275. // Highlights the selected menu item, onto which the menu cursor is placed
  276. function _menu_set()
  277. {
  278.     // cursor highlight has no effect in mouse mode
  279.     if(MOUSE_MODE >= 1) { menu_select.VISIBLE = OFF; RETURN; }
  280.  
  281.     // restrict the menu cursor to valid values
  282.     if(menu_cursor < 1) { menu_cursor = menu_max; }
  283.     if(menu_cursor > menu_max) { menu_cursor = 1; }
  284.  
  285.     // set the highlight panel onto the selected item, and make it visible
  286.     menu_select.POS_X = menu_pos.X + (menu_cursor-1) * menu_dist.X;
  287.     menu_select.POS_Y = menu_pos.Y + (menu_cursor-1) * menu_dist.Y;
  288.     menu_select.VISIBLE = ON;
  289.     _buttonclick();
  290. }
  291.  
  292. // Desc: exceutes the action of the selected menu item
  293. function _menu_exec()
  294. {
  295.     // if alt or ctrl was pressed, don't execute the menu but the old action
  296.     if(KEY_ALT || KEY_CTRL) { old_menu_enter(); return; }
  297.  
  298.     // now ececute the item action, dependent on the menu cursor position
  299.     play_sound(menu_click,60);
  300.     if(menu_cursor == 1) { _b1(); return; }
  301.     if(menu_cursor == 2) { _b2(); return; }
  302.     if(menu_cursor == 3) { _b3(); return; }
  303.     if(menu_cursor == 4) { _b4(); return; }
  304.     if(menu_cursor == 5) { _b5(); return; }
  305.     if(menu_cursor == 6) { _b6(); return; }
  306.     if(menu_cursor == 7) { _b7(); return; }
  307. }
  308.  
  309. function menu_show()
  310. {
  311.     _yesno_hide();    // if a yesno panel was active, hide it
  312.  
  313.     // First, set all button panels to their correct positions
  314.     menu_pan1.POS_X = menu_pos.X;
  315.     menu_pan1.POS_Y = menu_pos.Y;
  316.     menu_txt1.POS_X = menu_pos.X + menu_offs.X;
  317.     menu_txt1.POS_Y = menu_pos.Y + menu_offs.Y;
  318.     menu_pan2.POS_X = menu_pan1.POS_X + menu_dist.X;
  319.     menu_pan2.POS_Y = menu_pan1.POS_Y + menu_dist.Y;
  320.     menu_txt2.POS_X = menu_txt1.POS_X + menu_dist.X;
  321.     menu_txt2.POS_Y = menu_txt1.POS_Y + menu_dist.Y;
  322.     menu_pan3.POS_X = menu_pan2.POS_X + menu_dist.X;
  323.     menu_pan3.POS_Y = menu_pan2.POS_Y + menu_dist.Y;
  324.     menu_txt3.POS_X = menu_txt2.POS_X + menu_dist.X;
  325.     menu_txt3.POS_Y = menu_txt2.POS_Y + menu_dist.Y;
  326.     menu_pan4.POS_X = menu_pan3.POS_X + menu_dist.X;
  327.     menu_pan4.POS_Y = menu_pan3.POS_Y + menu_dist.Y;
  328.     menu_txt4.POS_X = menu_txt3.POS_X + menu_dist.X;
  329.     menu_txt4.POS_Y = menu_txt3.POS_Y + menu_dist.Y;
  330.     menu_pan5.POS_X = menu_pan4.POS_X + menu_dist.X;
  331.     menu_pan5.POS_Y = menu_pan4.POS_Y + menu_dist.Y;
  332.     menu_txt5.POS_X = menu_txt4.POS_X + menu_dist.X;
  333.     menu_txt5.POS_Y = menu_txt4.POS_Y + menu_dist.Y;
  334.     menu_pan6.POS_X = menu_pan5.POS_X + menu_dist.X;
  335.     menu_pan6.POS_Y = menu_pan5.POS_Y + menu_dist.Y;
  336.     menu_txt6.POS_X = menu_txt5.POS_X + menu_dist.X;
  337.     menu_txt6.POS_Y = menu_txt5.POS_Y + menu_dist.Y;
  338.     menu_pan7.POS_X = menu_pan6.POS_X + menu_dist.X;
  339.     menu_pan7.POS_Y = menu_pan6.POS_Y + menu_dist.Y;
  340.     menu_txt7.POS_X = menu_txt6.POS_X + menu_dist.X;
  341.     menu_txt7.POS_Y = menu_txt6.POS_Y + menu_dist.Y;
  342.  
  343.     // Now save the old actions of ESC, Cursor, ENTER keys into pointers
  344.     // and assign them them new actions required for the menu
  345.     old_menu_esc = ON_ESC;
  346.     ON_ESC = _menu_clear;    // now ESC clears the menu
  347.     old_cuu = ON_CUU;
  348.     on_cuu = _menu_up;        // CUU moves the selection cursor up
  349.     old_cud = ON_CUD;
  350.     on_cud = _menu_down;    // CUD moves it down
  351.     old_menu_enter = ON_ENTER;
  352.     ON_ENTER = _menu_exec;// and ENTER ececutes the selected item
  353.  
  354.     // and now place the menu cursor to the first item, and make the
  355.     // whole menu visible.
  356.     _menu_visible();
  357.     _menu_set();    // highlight first item
  358. }
  359.  
  360. ///////////////////////////////////////////////////////////////////////
  361. // Yes/No Panel stuff
  362. var yesno_active = 0;
  363.  
  364. // For saving and restoring the old key actions
  365. action* old_y;
  366. action* old_z;
  367. action* old_n;
  368.  
  369. // Action to execute if YES is clicked on
  370. action* yesno_do;
  371. function _yes_exec() { _yesno_clear(); yesno_do(); }
  372.  
  373. // The yes/no panel consists of 2 buttons, not surprisingly
  374. PANEL yesno_pan
  375. {
  376.     LAYER 12; BMAP yesno_back; FLAGS TRANSPARENT,REFRESH;
  377.     BUTTON YES_OFFS_X,YESNO_OFFS_Y,yesno_hi,yesno_low,yesno_hi,
  378.         _yes_exec,NULL,_buttonclick;
  379.     BUTTON NO_OFFS_X,YESNO_OFFS_Y,yesno_hi,yesno_low,yesno_hi,
  380.         _yesno_clear,NULL,_buttonclick;
  381. }
  382.  
  383. // Texts of the panel and the two buttons
  384. TEXT yesno_txt { LAYER 13; FONT menu_font; STRING empty_str; }
  385. TEXT yes_txt { LAYER 13; FONT menu_font; STRING yes_str; }
  386. TEXT no_txt { LAYER 13; FONT menu_font; STRING no_str; }
  387.  
  388. ///////////////////////////////////////////////////////////////////////
  389. // Initialzes the yesno panel
  390. function yesno_show()
  391. {
  392.     _menu_clear();        // in case menu was switched on before
  393.     _yesno_clear();    // remove last yesno
  394.  
  395.     // set the position of yesno panels and text
  396.     yesno_pan.POS_X = yesno_pos.X;
  397.     yesno_pan.POS_Y = yesno_pos.Y;
  398.     yesno_txt.POS_X = yesno_pan.POS_X + yesno_offs.X;
  399.     yesno_txt.POS_Y = yesno_pan.POS_Y + yesno_offs.Y;
  400.     yes_txt.POS_X = yesno_txt.POS_X + YES_OFFS_X;
  401.     yes_txt.POS_Y = yesno_txt.POS_Y + YESNO_OFFS_Y;
  402.     no_txt.POS_X = yesno_txt.POS_X + NO_OFFS_X;
  403.     no_txt.POS_Y = yes_txt.POS_Y;
  404.  
  405.     // let everything appear on screen
  406.     yesno_pan.VISIBLE = ON;
  407.     yesno_txt.VISIBLE = ON;
  408.     yes_txt.VISIBLE = ON;
  409.     no_txt.VISIBLE = ON;
  410.  
  411.     // Save the old key actions, and set the reqired panel actions
  412.     old_yesno_esc = ON_ESC;
  413.     ON_ESC = _yesno_clear;
  414.     old_n = ON_N;
  415.     ON_N = _yesno_clear;
  416.     old_yesno_enter = ON_ENTER;
  417.     ON_ENTER = _yes_exec;
  418.     old_y = ON_Y;
  419.     ON_Y = _yes_exec;
  420.     old_z = ON_Z;        // for German keyboard...
  421.     ON_Z = _yes_exec;
  422.  
  423.     yesno_active = 1;
  424.     FREEZE_MODE = 1;        // freeze game
  425. }
  426.  
  427. // let the yesno panel disappear
  428. function _yesno_hide()
  429. {
  430.     yesno_pan.VISIBLE = OFF;
  431.     yesno_txt.VISIBLE = OFF;
  432.     yes_txt.VISIBLE = OFF;
  433.     no_txt.VISIBLE = OFF;
  434. }
  435.  
  436. // exit the yesno panel
  437. function _yesno_clear()
  438. {
  439.     if (yesno_active)
  440.     {
  441.         _yesno_hide();
  442.         FREEZE_MODE = 0;        // unfreeze game
  443.         // restore old key actions
  444.         ON_ESC = old_yesno_esc;
  445.         ON_N = old_n;
  446.         ON_ENTER = old_yesno_enter;
  447.         ON_Y = old_y;
  448.         ON_Z = old_z;
  449.         yesno_active = 0;
  450.     }
  451. }
  452.  
  453. ///////////////////////////////////////////////////////////////////////
  454. // Options sliders stuff
  455. DEFINE SLIDER_LEN,70;
  456.  
  457. BMAP slider_map,<white.pcx>,0,0,10,10;
  458. BMAP slider_bar,<black.pcx>,0,0,SLIDER_LEN,2;
  459.  
  460. var bar_val1 = SLIDER_LEN;
  461. var bar_val2 = SLIDER_LEN; }
  462. var bar_val3 = SLIDER_LEN; }
  463. var slider_soundvol = 80;// 0, 100;
  464. var slider_musicvol = 50;//, 0, 100;
  465. var slider_resolution = 3;//, 1, 8;
  466.  
  467. PANEL option_pan
  468. {
  469.     LAYER 10;    FLAGS REFRESH;
  470.     HBAR 4,8,SLIDER_LEN,slider_bar,1,bar_val1;    // just to draw a black line
  471.     HSLIDER 4,4,SLIDER_LEN,slider_map,0,100,slider_soundvol;
  472.  
  473.     HBAR 4,28,SLIDER_LEN,slider_bar,1,bar_val2;
  474.     HSLIDER 4,24,SLIDER_LEN,slider_map,0,100,slider_musicvol;
  475.  
  476.     HBAR 4,48,SLIDER_LEN,slider_bar,1,bar_val3;
  477.     HSLIDER 4,44,SLIDER_LEN,slider_map,1,8,slider_resolution;
  478. }
  479.  
  480. STRING optionsound_str,"-  volume  +";
  481. STRING optionmusic_str,"-  music   +";
  482. STRING optionres_str,  "-  video   +";
  483.  
  484.  
  485. // move the cursor one slider up
  486. function _slider_up()
  487. {
  488.     if(MOUSE_MODE != 0) { RETURN; }
  489.     _buttonclick();
  490.     menu_cursor -= 1;
  491.     if(menu_cursor < 1) { menu_cursor = 3; }
  492. }
  493.  
  494. // move the cursor one slider down
  495. function _slider_down()
  496. {
  497.     if(MOUSE_MODE != 0) { RETURN; }
  498.     _buttonclick();
  499.     menu_cursor += 1;
  500.     if(menu_cursor > 3) { menu_cursor = 1; }
  501. }
  502.  
  503. // move selected slider to right
  504. function _slider_right()
  505. {
  506.     if(MOUSE_MODE != 0) { RETURN; }
  507.     _buttonclick();
  508.     if(menu_cursor == 1)
  509.     {
  510.         slider_soundvol += 10;
  511.         if(slider_soundvol > 100) { slider_soundvol = 100; }
  512.     }
  513.     if(menu_cursor == 2)
  514.     {
  515.         slider_musicvol += 10;
  516.         if(slider_musicvol > 100) { slider_musicvol = 100; }
  517.     }
  518.     if(menu_cursor == 3)
  519.     {
  520.         slider_resolution += 1;
  521.         if(slider_resolution > 8) { slider_resolution = 8; }
  522.     }
  523. }
  524.  
  525. // move selected slider to left
  526. function _slider_left()
  527. {
  528.     if(MOUSE_MODE != 0) { RETURN; }
  529.     _buttonclick();
  530.     if(menu_cursor == 1)
  531.     {
  532.         slider_soundvol -= 10;
  533.         if(slider_soundvol < 0) { slider_soundvol = 0; }
  534.     }
  535.     if(menu_cursor == 2) {
  536.         slider_musicvol -= 10;
  537.         if(slider_musicvol < 0) { slider_musicvol = 0; }
  538.     }
  539.     if(menu_cursor == 3)
  540.     {
  541.         slider_resolution -= 1;
  542.         if(slider_resolution < 1) { slider_resolution = 1; }
  543.     }
  544. }
  545.  
  546. function options_hide()
  547. {
  548.     if(slider_resolution != VIDEO_MODE)
  549.     {
  550.         SWITCH_VIDEO slider_resolution,0,0;
  551.         slider_resolution = VIDEO_MODE;
  552.         _show_resolution();
  553.     }
  554.     FREEZE_MODE = 0;
  555.     option_pan.VISIBLE = OFF;
  556.     menu_txt1.VISIBLE = OFF;
  557.     menu_txt2.VISIBLE = OFF;
  558.     menu_txt3.VISIBLE = OFF;
  559.     ON_ESC = old_menu_esc;
  560.     ON_CUU = old_cuu;
  561.     ON_CUD = old_cud;
  562.     ON_CUL = old_cul;
  563.     ON_CUR = old_cur;
  564. }
  565.  
  566. // Yet to do: modularize a slider panel
  567. function game_options()
  568. {
  569.     EXCLUSIVE_GLOBAL;
  570.     FREEZE_MODE = 1;
  571.     option_pan.POS_X = menu_pos.X;
  572.     option_pan.POS_Y = menu_pos.Y;
  573.     menu_txt1.POS_X = menu_pos.X + 2;
  574.     menu_txt1.POS_Y = menu_pos.Y + 15;
  575.     menu_txt2.POS_X = menu_txt1.POS_X;
  576.     menu_txt2.POS_Y = menu_txt1.POS_Y + 20;
  577.     menu_txt3.POS_X = menu_txt2.POS_X;
  578.     menu_txt3.POS_Y = menu_txt2.POS_Y + 20;
  579.     option_pan.VISIBLE = ON;
  580.     menu_txt1.VISIBLE = ON;
  581.     menu_txt2.VISIBLE = ON;
  582.     menu_txt3.VISIBLE = ON;
  583.     menu_txt1.STRING = optionsound_str;
  584.     menu_txt2.STRING = optionmusic_str;
  585.     menu_txt3.STRING = optionres_str;
  586.     old_menu_esc = ON_ESC;
  587.     ON_ESC = options_hide;
  588.     old_cuu = ON_CUU;
  589.     ON_CUU = _slider_up;
  590.     old_cud = ON_CUD;
  591.     ON_CUD = _slider_down;
  592.     old_cul = ON_CUL;
  593.     ON_CUL = _slider_left;
  594.     old_cur = ON_CUR;
  595.     ON_CUR = _slider_right;
  596.  
  597.     menu_cursor = 1;
  598.     slider_soundvol = SOUND_VOL;
  599.     slider_musicvol = MIDI_VOL;
  600.     slider_resolution = VIDEO_MODE;
  601.  
  602.     while(option_pan.VISIBLE == ON)
  603.     {
  604.         if(MOUSE_MODE == 0)
  605.         {
  606.             if(menu_cursor == 1)
  607.             {
  608.                 if(bar_val1 == 0)
  609.                 {
  610.                     bar_val1 = SLIDER_LEN;
  611.                 }
  612.                 else
  613.                 {
  614.                     bar_val1 = 0;
  615.                 }
  616.                 bar_val2 = SLIDER_LEN;
  617.                 bar_val3 = SLIDER_LEN;
  618.             }
  619.             if(menu_cursor == 2)
  620.             {
  621.                 if(bar_val2 == 0)
  622.                 {
  623.                     bar_val2 = SLIDER_LEN;
  624.                 }
  625.                 else
  626.                 {
  627.                     bar_val2 = 0;
  628.                 }
  629.                 bar_val1 = SLIDER_LEN;
  630.                 bar_val3 = SLIDER_LEN;
  631.             }
  632.             if(menu_cursor == 3)
  633.             {
  634.                 if(bar_val3 == 0)
  635.                 {
  636.                     bar_val3 = SLIDER_LEN;
  637.                 }
  638.                 else
  639.                 {
  640.                     bar_val3 = 0;
  641.                 }
  642.                 bar_val2 = SLIDER_LEN;
  643.                 bar_val1 = SLIDER_LEN;
  644.             }
  645.         }
  646.         else
  647.         {
  648.              bar_val1 = SLIDER_LEN;
  649.              bar_val2 = SLIDER_LEN;
  650.              bar_val3 = SLIDER_LEN;
  651.         }
  652.         SOUND_VOL = slider_soundvol;
  653.         MIDI_VOL = slider_musicvol;
  654.         wait(1);
  655.     }
  656. }
  657.  
  658. ///////////////////////////////////////////////////////////////////////
  659. // save/load stuff
  660. var slot    = 0;     // number of last score
  661. function _menu_save1() { slot = 1; mystring = name1_str; _game_save(); }
  662. function _menu_save2() { slot = 2; mystring = name2_str; _game_save(); }
  663. function _menu_save3() { slot = 3; mystring = name3_str; _game_save(); }
  664. function _menu_save4() { slot = 4; mystring = name4_str; _game_save(); }
  665. function _menu_save5() { slot = 5; mystring = name5_str; _game_save(); }
  666.  
  667. function _menu_save()
  668. {
  669.     menu_txt1.STRING = name1_str;
  670.     menu_txt2.STRING = name2_str;
  671.     menu_txt3.STRING = name3_str;
  672.     menu_txt4.STRING = name4_str;
  673.     menu_txt5.STRING = name5_str;
  674.     menu_txt6.STRING = resume_str;
  675.  
  676.     menu_do1 = _menu_save1;
  677.     menu_do2 = _menu_save2;
  678.     menu_do3 = _menu_save3;
  679.     menu_do4 = _menu_save4;
  680.     menu_do5 = _menu_save5;
  681.     menu_do6 = _menu_clear;
  682.  
  683.     menu_max = 6;
  684.     menu_show();
  685. }
  686.  
  687.  
  688. function load_status()
  689. {
  690.     wait(2);    // don't override previous LOAD etc.
  691.     LOAD_INFO INFO_NAME,0;
  692. }
  693.  
  694. function _game_save()
  695. {
  696.     _menu_visible();    // was hidden before
  697.     INKEY    mystring;
  698.     if(RESULT != 13) { _menu_clear(); return; }
  699.     _menu_clear();
  700.     save_status();            // save global skills & strings
  701.     ON_LOAD = load_status;    // to automatically reload them
  702.  
  703. //    msg.STRING = wait_str;
  704. //    show_message();
  705.  
  706.     save(SAVE_NAME,slot);    // save game
  707.     if(RESULT < 0)
  708.     {        // Error?
  709.         msg.STRING = save_error;
  710.     }
  711.     else
  712.     {
  713.         msg.STRING = ok_str;
  714.     }
  715.     show_message();
  716. }
  717.  
  718.  
  719. // after re-loading a game, reload all global parameters
  720. function save_status()
  721. {
  722.     save_info(INFO_NAME,0);
  723. }
  724.  
  725. ///////////////////////////////////////////////////////////////////////
  726. function help_hide()
  727. {
  728.     FREEZE_MODE = 0;
  729.     msg.VISIBLE = OFF;
  730.     ON_ESC = old_help_esc;
  731.     ON_F1 = old_f1;
  732. }
  733.  
  734. function game_help()
  735. {
  736.     FREEZE_MODE = 1;
  737.     msg.STRING = helptxt_str;
  738.     msg.VISIBLE = ON;
  739.     old_help_esc = ON_ESC;
  740.     ON_ESC = help_hide;
  741.     old_f1 = ON_F1;
  742.     ON_F1 = help_hide;
  743. }
  744.  
  745. ///////////////////////////////////////////////////////////////////////
  746. // menu actions for a standard game
  747.  
  748. function _menu_load1() { slot = 1; _game_load(); }
  749. function _menu_load2() { slot = 2; _game_load(); }
  750. function _menu_load3() { slot = 3; _game_load(); }
  751. function _menu_load4() { slot = 4; _game_load(); }
  752. function _menu_load5() { slot = 5; _game_load(); }
  753.  
  754. function _menu_load()
  755. {
  756.     menu_txt1.STRING = name1_str;
  757.     menu_txt2.STRING = name2_str;
  758.     menu_txt3.STRING = name3_str;
  759.     menu_txt4.STRING = name4_str;
  760.     menu_txt5.STRING = name5_str;
  761.     menu_txt6.STRING = resume_str;
  762.  
  763.     menu_do1 = _menu_load1;
  764.     menu_do2 = _menu_load2;
  765.     menu_do3 = _menu_load3;
  766.     menu_do4 = _menu_load4;
  767.     menu_do5 = _menu_load5;
  768.     menu_do6 = _menu_clear;
  769.  
  770.     menu_max = 6;
  771.     menu_show();
  772. }
  773.  
  774. function game_exit()
  775. {
  776.     save_status();            // save global skills & strings
  777.     EXIT    "3D GameStudio (c) conitec 2001\n";
  778. }
  779.  
  780. function exit_yesno()
  781. {
  782.     yesno_txt.STRING = quit_yesno;
  783.     yesno_do = game_exit;
  784.     yesno_show();
  785. }
  786.  
  787. // Desc: default action, to be replaced by a game-adapted action
  788. function game_init()
  789. {
  790.     key_init();
  791.     weapon_init();
  792.     main();
  793. }
  794.  
  795. // dummy actions, if weapons.wdl or doors.wdl are not included
  796. function weapon_init() { return; }
  797. function key_init() { return; }
  798.  
  799. function menu_main()
  800. {
  801.     menu_txt1.STRING = new_game_str;
  802.     menu_txt2.STRING = load_game_str;
  803.     menu_txt3.STRING = save_game_str;
  804.     menu_txt4.STRING = quit_game_str;
  805.     menu_txt5.STRING = options_str;
  806.     menu_txt6.STRING = help_str;
  807.     menu_txt7.STRING = resume_str;
  808.  
  809.     menu_do1 = game_init;    // normally an action which resets all
  810.     menu_do2 = _menu_load;
  811.     menu_do3 = _menu_save;
  812.     menu_do4 = exit_yesno;
  813.     menu_do5 = game_options;
  814.     menu_do6 = game_help;
  815.     menu_do7 = _menu_clear;
  816.  
  817.     menu_max = 7;
  818.     menu_show();
  819. }
  820.  
  821. VAR_INFO _entry = 0; // { TYPE GLOBAL; VAL 0; }
  822. function game_entry()
  823. {    // mark the score to re-enter the game (yet to do)
  824.     if(_entry == 0)
  825.     {
  826.         _entry = 1;
  827.     }
  828. }
  829.  
  830.  
  831. ///////////////////////////////////////////////////////////////////////
  832. function _game_load()
  833. {
  834.     msg.STRING = wait_str;
  835.     show_message();
  836.     wait(1);                // to display wait message before loading
  837.  
  838.     load(SAVE_NAME,slot);
  839.     msg.STRING = load_error;    // failed!
  840.     show_message();
  841. }
  842.  
  843. ///////////////////////////////////////////////////////////////////////////////////
  844. // Desc: switches the mouse on and off
  845. function mouse_toggle()
  846. {
  847.     MOUSE_MODE += 2;
  848.     if(MOUSE_MODE > 2)
  849.     {    // was it already on?
  850.         MOUSE_MODE = 0;        // mouse off
  851.     }
  852.     else
  853.     {
  854.         mouse_on();
  855.     }
  856. }
  857.  
  858. // Desc: switches the mouse on
  859. function mouse_on()
  860. {
  861.     menu_select.VISIBLE = OFF;    // menu now handled by mouse
  862.     MOUSE_MAP = arrow;
  863.     while(MOUSE_MODE > 0)
  864.     {
  865.         MOUSE_POS.X = POINTER.X;
  866.         MOUSE_POS.Y = POINTER.Y;
  867.         wait(1);               // now move it over the screen
  868.     }
  869. }
  870.  
  871. // Desc: switches the mouse off
  872. function mouse_off()
  873. {
  874.     MOUSE_MODE = 0;
  875. }
  876.  
  877. //var MOUSE_SPOT[2] = 5,5;
  878.  
  879. ////////////////////////////////////////////////////////////////////////////
  880. // For debugging purposes, use the EXECUTE instruction
  881. // to type in WDL instructions during gameplay, like at a console.
  882. // You can examine skill values through "TO_STRING look,skill;"
  883.  
  884. STRING exec_buffer    // just an 80-char string
  885. "                                                                              ";
  886. STRING look "         "; // to see skills via TO_STRING;
  887.  
  888. TEXT console_txt
  889. {
  890.     POS_X 4;
  891.     LAYER    10;
  892.     FONT     standard_font;
  893.     STRINGS 3;
  894. IFDEF CONSOLE_MODE_2;
  895.     STRING "Enter instructions below, abort with [ESC]:";
  896. IFELSE;
  897.     STRING "Enter instructions below:";
  898. ENDIF;
  899.     STRING exec_buffer;
  900.     STRING look;
  901. }
  902.  
  903. function console()
  904. {
  905.     if(console_txt.VISIBLE == ON) { RETURN; }    //already running
  906.     console_txt.POS_Y = SCREEN_SIZE.Y - 60;
  907.     console_txt.VISIBLE = ON;
  908.     while(console_txt.VISIBLE == ON)
  909.     {
  910.         INKEY    exec_buffer;
  911.         if(RESULT == 13)
  912.         {
  913.             EXECUTE exec_buffer;
  914. IFDEF CONSOLE_MODE_2;
  915.         }
  916.         else
  917.         {
  918.             console_txt.VISIBLE = OFF;
  919.         }
  920. IFelse;
  921.         }
  922.         console_txt.VISIBLE = OFF;
  923. ENDIF;
  924.     }
  925. }
  926.  
  927. // Implementing a scrolling console, instead of a 1-line one,
  928. // is left as an exercise to the reader...
  929.  
  930. //////////////////////////////////////////////////////////////
  931. // screen resolution display
  932. //////////////////////////////////////////////////////////////////////
  933. STRING resolution_str,"                              ";
  934. STRING screen_str,"Video ";
  935. STRING x_str,"x";
  936.  
  937. // Mod Date: 11/1/00 DCP
  938. //        Replaced to_string, add_string, and set_string with
  939. //    str_for_num, str_cat, and str_cpy
  940. function _show_resolution()
  941. {
  942.     // compose the resolution string from strings and numbers
  943.     str_cpy(resolution_str,screen_str);
  944.  
  945.     // now it reads "Video "
  946.     str_for_num(temp_str,SCREEN_SIZE.X);
  947.     str_cat(resolution_str,temp_str);
  948.     // now it reads "Video hhhh" (hhhh is the hor resolution)
  949.     str_cat(resolution_str,x_str);
  950.     // now it reads "Video hhhhx"
  951.     str_for_num(temp_str,SCREEN_SIZE.Y);
  952.     str_cat(resolution_str,temp_str);
  953.     // now it reads "Video hhhhxvvvv"
  954.     str_cat(resolution_str,x_str);
  955.     // now it reads "Video hhhhxvvvvx"
  956.     str_for_num(temp_str,VIDEO_DEPTH);
  957.     str_cat(resolution_str,temp_str);
  958.     // and now it reads "Video hhhhxvvvvxdd"
  959.  
  960.     msg.STRING = resolution_str;
  961.     show_message();
  962. }
  963.  
  964. function game_resolution()
  965. {
  966.     _toggle_video();
  967.     _show_resolution();
  968. }
  969.  
  970. //////////////////////////////////////////////////////////////////////
  971. // Default key assignements to control the game
  972. ON_ESC menu_main;
  973. ON_F1     game_help;
  974. ON_F5     game_resolution;
  975. ON_F10 exit_yesno;
  976. ON_TAB console;
  977.  
  978. ON_MOUSE_RIGHT    mouse_toggle;